#!/usr/bin/env python2.4
__license__ = "GNU Lesser General Public License, Ver.2"
__author__ = "Grigory Bakunov <bobuk@justos.org>"

from config import *
import web
import wmconfig
import os

def raiseError(errno, retpath=None):
    if retpath == None:
        retpath = ''
    cfg = wmconfig.Config()
    web.redirect('%s/error/%d' % (cfg.cfg['c_abspath'], errno) )

class error:
    def GET(self, errcode):
        errno = int(errcode)
        web.render('error.html')

class player:
    def GET(self):
        web.header('Content-Type', 'application/x-shockwave-flash')
        print open(ssPath + 'mpb.swf').read()
    def POST(self):
        web.header('Content-Type', 'application/x-shockwave-flash')
        print open(ssPath + 'mpb.swf').read()
        

mime = {
    '.css': 'text/css',
    '.html': 'text/html',
    '.cfg': 'text/cfg',
    }

class semistatic:
    def GET(self, sspath):
        _pt = os.path.join('templates', ssPath,
                           sspath.replace('..','').replace('/',''))
        nfn = sspath[-4:]
        if mime.has_key(nfn):
            web.header('Content-Type', mime[nfn])
        cfg = wmconfig.Config()
        print open(_pt).read() % cfg.cfg

